# -*- coding: utf-8 -*-
# @Time : 2021/9/10 12:04
# @Author : 阿怪
# @Email : scg@gmail.com
# @File : CRM-ST-ZNX-13.py
# @Project : crm自动化测试项目实战

'''验证站内信发送功能—选择用户进行站内信的发送'''

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Chrome()
cookie = {'name': 'PHPSESSID', 'value': '0onrpth7nsd6mbi1hfgi99o2b1'}  # 获取到cookid
driver.get('http://192.168.1.140/')  # 访问服务器
driver.add_cookie(cookie)
driver.get('http://192.168.1.140/crm3/index.php?m=message')
#进入站内信首页


#1.点击写信进入编辑界面
add_send_locator = (By.ID,'send')
driver.find_element(*add_send_locator).click()
sleep(3)

#2.输入信息啥的
text_locator = (By.NAME,'content')   #内容输入框定位器
submit_locator = (By.NAME,'submit')    #发送按钮定位器

driver.find_element(By.CSS_SELECTOR,'#ta1 > input').click()    #点击全选
driver.find_element(*text_locator).send_keys('我是测试')
#3.点击发送
driver.find_element(*submit_locator).click()   #点击发送
sleep(2)

#4.断言，首页出现’			发送成功		‘就通过  #
pass_text = driver.find_element(By.CSS_SELECTOR,'body > div.container > div.alert.alert-success').text
print(pass_text)

driver.quit()